<?php
require_once('wxsdk.php');
define("TOKEN", "weixin");
setlocale(LC_ALL, 'zh_CN.utf-8');
header("Content-Type:text/html;charset=utf-8");



$wechatObj = new wechatCallbackapiTest("wxf26b83f0a766a32b","cafd55d65bbba76243e7de3dc46bdeb4");

$redis = new redis(); 
$redis->connect('127.0.0.1', 6379); 

echo date("Y-m-d H:i:s");
echo "\n";

$redis->rPush('YJ','oS2iHxDnuaAqSSjPIAyWZsZai4ds');

while (true) {
  
  echo date("Y-m-d H:i:s");
  echo "\n";
  sleep(1);

  $now=date("Y-m-d H:i:s");

  $len=$redis->lSize('YJ');
  if($len){
    $openid=$redis->rPop('YJ');

    echo $openid;
    echo "\n";
    $template=array(
             'touser'=>$openid,
             'template_id'=>"XGMB2zPDRMBIDmlJ2vD29g3cdX_VmfhBBxONNUAx6zs",
             'url'=>"http://open.weixin.qq.com/qr/code/?username=wxzhifu",            
             'data'=>array(
                     'first'=> array(
                         'value'=>urlencode("尊敬的赚米吧会员，您好，2月15，16，17，18，19五天累计佣金已经到账，请注意查收"),
                         'color'=>"#173177"                                                        
                      ),
                     'keyword1'=>array(
                         'value'=>urlencode("赚米8的企业付款"),
                         'color'=>"#173177"
                     ),
                     'keyword2'=> array(
                         'value'=>urlencode("以实际到账为准"),
                         'color'=>"#173177"
                     ),
                     'keyword3'=> array(
                         'value'=>date("Y-m-d H:i:s"),
                         'color'=>"#173177"
                     ),
                     'remark'=>array(
                         'value'=>urlencode("点击扫码查看到账详情"),
                         'color'=>"#173177"
                     )
              )
      );

      $ret = $wechatObj->send_template_message(urldecode(json_encode($template)));

      var_dump($ret);
      echo "\n";

      echo '发送成功';
      echo "\n";


  }

}
?>








